package com.hmall.api.client.fallback;

import com.hmall.api.client.ItemClient;
import com.hmall.api.client.TradeClient;
import com.hmall.api.dto.ItemDTO;
import com.hmall.api.dto.OrderDetailDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * 自定义FallbackFactory
 */
@Slf4j
public class TradeClientFallbackFactory implements FallbackFactory<TradeClient> {
    /**
     * 调用失败后的后备解决方案
     * @param cause
     * @return
     */
    @Override
    public TradeClient create(Throwable cause) {
       return new TradeClient() {
           @Override
           public void markOrderPaySuccess(Long orderId) {
               throw new RuntimeException(cause);
           }
       };
    }
}
